package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.networkassets.dict;

import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;

/**
 * IT网络资产字典字段值
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_it_net_assets_dict_field_value set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_it_net_assets_dict_field_value set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_it_net_assets_dict_field_value", indexes = {@Index(name = "UK_CODE", columnList = "dict_code, dict_field_code, record_id, deleted", unique = true),
        @Index(name = "IDX_DICT_FIELD", columnList = "dict_field_code")})
public class ItNetworkAssetsDictFieldValue extends BaseEntity {

    private static final long serialVersionUID = -6955396326468693872L;

    @Column(name = "dict_code", columnDefinition = "varchar(128) not null comment '字典code'")
    private String dictCode;

    @Column(name = "dict_field_code", columnDefinition = "varchar(128) not null comment '字段code'")
    private String dictFieldCode;

    @Column(name = "value", columnDefinition = "varchar(512) not null comment '字段值'")
    private String value;

    @Column(name = "record_id", columnDefinition = "bigint not null comment '字典值记录id'")
    private Long recordId;
}
